/*
 * @Author: 肖芬芳 1911683843@qq.com
 * @Date: 2022-09-23 15:39:12
 * @LastEditors: 肖芬芳 1911683843@qq.com
 * @LastEditTime: 2022-12-07 10:33:18
 * @FilePath: \node_studyc:\Users\Administrator\Desktop\vite-project\src\views\system\user\api\userServieApi.ts
 * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
 */
import { ServerResponse } from '@/util/base/ServerResponse'
import { Request } from '@/util/http/axios'
import { UserListVo } from '../Vo/userVo'
import { SearchList,statusParams ,userParams} from '../params/searchParams'

export default class UserServiceApi {
  async getUserList (searchList: SearchList): Promise<ServerResponse<UserListVo>> {
    const res = await Request.post<ServerResponse<UserListVo>, SearchList>(
      '/user/list',
      searchList)
    return res.data
  }

  async addUser (userParams:userParams): Promise<ServerResponse<UserListVo>> {
    const res = await Request.post<ServerResponse<UserListVo>, userParams>(
      '/user/add',
      userParams)
    return res.data
  }

  async changeStatus (statusParams:statusParams): Promise<ServerResponse<UserListVo>> {
    const res = await Request.post<ServerResponse<UserListVo>, statusParams>(
      '/user/changeStatus',
      statusParams)
    return res.data
  }

  // 获取角色详情
  // 模板字符串拼接字符串
  async detail(id:string):Promise<ServerResponse<UserListVo>>{
    const res = await Request.get<ServerResponse<UserListVo>, string>(
      `/user/detail/${id}`)
    return res.data
  }

  // 编辑角色
  async modifyUser (userParams:userParams): Promise<ServerResponse<UserListVo>> {
    const res = await Request.post<ServerResponse<UserListVo>, userParams>(
      '/user/modify',
      userParams)
    return res.data
  }

  // 获取角色列表
  async roleSelector():Promise<ServerResponse<UserListVo>> {
    const res = await Request.get<ServerResponse<UserListVo>,any>(
      '/role/selector')
    return res.data
  }
}
